package com.example.edspquery;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.springframework.stereotype.Service;

@Service
public class QueryTemplate {

    public JSONObject myTaskPage(int page, int size) {

        JSONObject param = JSONUtil.parseObj("{\"page\":1,\"size\":50,\"sortField\":\"\",\"sortType\":\"\",\"queryType\":\"3\",\"statusList\":[]}");
        param.putOpt("page", page);
        param.putOpt("size", size);

        String body = HttpRequest.post(EdspQueryUrl.MY_TASK_PAGE).header("Authorization", getToken())
                .body(param.toString())
                .execute()
                .body();
        return JSONUtil.parseObj(body);
    }

    //关联的需求是处理中才能重新打开
    public JSONObject reOpenTask(Long taskId) {
        String body = HttpRequest.post(EdspQueryUrl.RE_OPEN_TASK)
                .header("Authorization", getToken())
                .form("taskId", taskId)
                .execute()
                .body();
        return JSONUtil.parseObj(body);
    }



    private String getToken() {
        return "Bearer eyJhbGciOiJSUzI1NiJ9.eyJsb2dpbklkIjoiMjEwNTE0NTgiLCJ1c2VyTmFtZSI6IuaWueaYjuWdpCIsImV4cCI6MTcxOTc0OTQ5MywidXNlcklkIjoxNjQwNTQ3MjQzOTc0NzkxNzM5fQ.Usw4wgS6gaN1G_21erhXgbYxOwUqzYngCQlSw-QLeYlFYg2ItTI-hkwkQmeKVagZkvVv-ztgRBCedg1ZF7_23EfwY_j6ulKVxdgD2gc8kurz470nUmcJ5QLdoyH5oPclb4NIMiE8VfXcMGOdwW7-N384h6PTDEOdDcntwVNy-9nJx27JuLtoIQ5kY9MTVGfYYMofo8EPV0zW3_5bHRSwbiMObKtAZg-M7Q9HOA0p94X9ucqjvpeSu6nxNb6s80NwP0uY-7UIBmSFw1-Az16tOEMr8ct1hEoel4V5tBtoel3kzzTgAujyS7CEsAbF6notkxmryl4Yl6ts4W34B-ffrg";
    }
}
